<?php

/**
 * LEAGUEMan
 * 
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
class LM_Table_Player extends LM_Table
{
    /** @var int Primary Key */
    public $player_id;
    /** @var string name */
    public $player_name;
    /** @var string player_name_first */
    public $player_name_first;
    /** @var string player_name_last */
    public $player_name_last;
    /** @var int male/female */
    public $player_sex;
    /** @var date born */
    public $player_born;
    /** @var date died */
    public $player_died;
    /** @var string country */
    public $player_country;
    /** @var int weight attribute */
    public $player_weight;
    /** @var int height attribute */
    public $player_height;
    /** @var string text */
    public $player_text;
    /** @var string image */
    public $player_image;
    /** @var bool is_referee */
    public $player_is_referee;
    /** @var bool is_trainer */
    public $player_is_trainer;
    /** @var timestamp creation datetim */
    public $created;
    /** @var int references mosUser */
    public $created_by;
    /** @var int state 1 = published, 2 = approved */
    public $player_state;

    function __construct($db)
    {
        parent::__construct('#__leagueman_player', 'player_id', $db);
    }

    function getID()
    {
        return $this->player_id;
    }

    function getName()
    {
        return $this->player_name;
    }

    function getFirstname()
    {
        return $this->player_name_first;
    }

    function getLastname()
    {
        return $this->player_name_last;
    }

    function getBirthday()
    {
        return $this->player_born;
    }

    function getDeathday()
    {
        return $this->player_died;
    }

    function getCountry()
    {
        return $this->player_country;
    }

    function getImage()
    {
        return $this->player_image;
    }

    function getHeight()
    {
        return $this->player_height;
    }

    function getWeight()
    {
        return $this->player_weight;
    }

    function getText()
    {
        return $this->player_text;
    }

    function getState()
    {
        return $this->player_state;
    }

    function check()
    {
        global $my;

        if (empty($this->player_name)) {
            $this->player_name = sprintf("%s %s", $this->player_name_first, $this->player_name_last);
        }

        if (empty($this->player_name)) {
            return false;
        }

        if (!$this->player_id) {
            $this->created = date("Y-m-d H:i:s");
            $this->created_by = $my->id;
        }

        return true;
    }

}